package com.shengzai.rdd

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo4FlatMap {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
    conf.setAppName("FlatMap")
    conf.setMaster("local")
    val sc = new SparkContext(conf)

    val wordRDD: RDD[String] = sc.textFile("hadoop_code/src/data/worlds.txt")
    //列转行
    val worlds: RDD[String] = wordRDD.flatMap(
      line => line.split(" ")
    )
    worlds.foreach(println)
  }

}
